using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Text.RegularExpressions;

namespace HubLog
{
    public class RemoteSource
    {
        //
        private string _InstanceName;
        //
        private string _Host;
        private Int16 _Port;
        private string _UserName;
        private string _Password;
        //
        private Color _InstanceColor;
        private Regex _rx;
        //
        private bool _VeryImportant;
        private UserFunc _UserFunc;
        //
        public string InstanceName { get { return this._InstanceName; } }
        //
        public string Host { get { return this._Host; } }
        public Int16 Port { get { return this._Port; } }
        public string UserName { get { return this._UserName; } }
        public string Password { get { return this._Password; } }
        //
        public Color InstanceColor { get { return this._InstanceColor; } }
        public Regex RegularExpression { set { _rx = value; } get { return this._rx; } }
        //
        public bool VeryImportant { get { return this._VeryImportant; } }
        public UserFunc UserFunction { get { return this._UserFunc; } }
        //
        public RemoteSource()
        {
            _InstanceName = String.Empty;
            //
            _Host = String.Empty;
            _Port = 0;
            _UserName = String.Empty;
            _Password = String.Empty;
            //
            _InstanceColor = Color.Black;
            _rx = null;
            //
            _VeryImportant = false;
            _UserFunc = null;
        }
        //
        public void Set(String InstanceName, String Host, String Port, String UserName, String Password, String InstanceColor, bool VeryImportant, String UserFunc)
        {
            this._InstanceName = InstanceName.Trim();
            //
            this._Host = Host.Trim();
            this._Port = Int16.Parse(Port.Trim());
            this._UserName = UserName.Trim();
            this._Password = Password.Trim();
            //
            this._InstanceColor = Color.FromName(InstanceColor);
            //
            _VeryImportant = VeryImportant;
            //_UserFunc =
            if (string.Empty != UserFunc.Trim())
            {
                UserFunc _uf = new UserFunc();
                if (_uf.CompileFromString(UserFunc.Trim())) _UserFunc = _uf;
            }
        }
        //
        public override string ToString()
        {
            return this._InstanceName + "," + this._Host + "," + this._Port.ToString() + "," + this._UserName + "," + this._Password + "," + this._InstanceColor.ToString() + "," +_rx.ToString()+ "," + _VeryImportant.ToString() + ".";
        }
        //
    }//class
}//namespace
